Attribute VB_Name = "Module12"
Private Declare Function ECF_UltimoItemVendido Lib "CONVECF.DLL" (ByVal UltimoItem As String) As Integer
Private Declare Function ECF_SubTotal Lib "CONVECF.DLL" (ByVal SubTotal As String) As Integer
Private Declare Function ECF_SubTotalComprovanteNaoFiscalMFD Lib "CONVECF.DLL" (ByVal SubTotalCNF As String) As Integer
Private Declare Function ECF_ValorPagoUltimoCupom Lib "CONVECF.DLL" (ByVal Valor As String) As Integer
Private Declare Function ECF_NumeroCupom Lib "CONVECF.DLL" (ByVal NumCupom As String) As Integer
Private Declare Function ECF_VerificaFormasPagamentoMFD Lib "CONVECF.DLL" (ByVal FormasPag As String) As Integer


Function UltimoItemVendido()
    Dim item As String
    
    item = Space(4)
    retorno = ECF_UltimoItemVendido(item)
    
    MsgBox " 'Último Item Vendido' " & vbCrLf & "Status: " & retorno
    Form1.List1.AddItem "Último Item Vendido: " & item
End Function

Function SubTotalCF()
    Dim SubTot As String
    
    SubTot = Space(14)
    retorno = ECF_SubTotal(SubTot)
    
    MsgBox " 'Subtotal do Cupom Fiscal' " & vbCrLf & "Status: " & retorno
    Form1.List1.AddItem "Subtotal: " & SubTot
End Function

Function SubTotalCNF()
    Dim SubTotCNF As String
    
    SubTotCNF = Space(14)
    retorno = ECF_SubTotalComprovanteNaoFiscalMFD(SubTotCNF)
    
    MsgBox " 'Subtotal do Comprovante' " & vbCrLf & "Status: " & retorno
    Form1.List1.AddItem "Subtotal Comprovante: " & SubTotCNF
End Function

Function ValorPagoUltimoCupom()
    Dim Val As String
    
    Val = Space(14)
    retorno = ECF_ValorPagoUltimoCupom(Val)
    
    MsgBox " 'Valor Pago no Último Cupom' " & vbCrLf & "Status: " & retorno
    Form1.List1.AddItem "Valor Pago: " & Val
End Function

Function NumeroCupom()
    Dim NCupom As String
    
    NCupom = Space(6)
    retorno = ECF_NumeroCupom(NCupom)
    
    MsgBox " 'Nº do Cupom' " & vbCrLf & "Status: " & retorno
    Form1.List1.AddItem "Nº do Cupom: " & NCupom
End Function

Function VerificaFormasPagamento()
    Dim ForPag As String, temp As String
    Dim I As Integer, pos As Integer
    
    ForPag = Space(919)
    
    retorno = ECF_VerificaFormasPagamentoMFD(ForPag)
    
    MsgBox " 'Verifica Forma de Pagamento' " & vbCrLf & "Status: " & retorno
    pos = 1
    I = 1
    Form1.List1.AddItem "Formas de Pagamento:"
    Do While pos > 0
            
            pos = InStr(1, ForPag, ",")
            
            If pos > 0 Then
                temp = Left(ForPag, pos - 1)
                ForPag = Right(ForPag, Len(ForPag) - pos)
                Form1.List1.AddItem "    " & Right("0" + CStr(I), 2) & ": " & temp
                I = I + 1
            End If
    Loop

End Function

